

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )

	self.Angle = data:GetAngle()
	self.LifeTime = CurTime() + math.Rand( 15, 20 )

	local count = table.Count( HeadshotGibs )
	local model = HeadshotGibs[ math.random( 1,count ) ]
	if (model == nil) then model = "models/gibs/HGIBS_scapula.mdl" end

	self:SetModel( model )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS ) 
	self:SetPos(data:GetOrigin() + (VectorRand() * math.random( -5, 5 )))
	
	self:SetMaterial( "models/flesh" )
	
	local phys = self:GetPhysicsObject()
	
	if (!phys:IsValid()) then
		self:Remove()
		print("Error! "..model.." is not a valid prop model!\n")
	end
	
	if ( phys && phys:IsValid() ) then
	
		phys:Wake()
		phys:SetAngle( Angle( math.Rand(0,359), math.Rand(0,359), math.Rand(0,359) ) )
		phys:SetVelocity((Vector(1,1,0) * math.Rand( 40, 80 )) + self.Angle:Forward() * math.random(20,40))
		phys:AddAngleVelocity(Angle(math.random(-250,250),math.random(-250,250),math.random(-250,250)))
	
	end
	
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )

	if self.LifeTime >= CurTime() then
		return true
	else
		return false
	end
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	self:DrawModel()

end



